<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑导图</title>
    <link rel="stylesheet" href="/css/build.css">
    <link rel="stylesheet" href="/css/d3.css">
    <link rel="stylesheet" href="/css/main.css" type="text/css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.5/sweetalert2.min.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.5/sweetalert2.min.js"></script>
</head>
<style>
        #container {
            display: flex;
            height: 800px;
        }
        #example {
            overflow: auto;
            flex: 1;
        }
        #tree {
            flex: 1;
        }
        </style>
<body>
<div class="header">
<span class="leftpoint"></span>
    <a href="/hd/node/parentlist" class="lab btn">发布领域</a>
    <a class="lab selected btn">发布节点</a>
    <a href="/hd/editlist" class="lab btn">编辑记录</a>
    <a href="/hd/recordlist" class="lab btn">更改申请</a>
    {{template "hd/nav.html" .}}
</div>
<div class="nav-bar">
    <span class="nav-title">发布节点</span>
    <span class="nav-smtitle">子领域</span>
    <span onclick="save()" style="
    background: #3454f4;
    border-radius:4px;
    width:161px;
    height:36px;
    display: inline-block;
    font-size:14px;
    color:#ffffff;
    line-height:19px;
    text-align:center;
    line-height: 36px;
    float: right;
    margin-top: 14px;
    margin-right: 30px;
    cursor: pointer;
">保存</span>
</div>
<div class="main" style="padding-left:20px;padding-right:20px">
        <div id="container">
                <div id="example"></div>
                <div id="tree"></div>
        </div>


</div>
</body>
<script>
    var id={{.Id}};
    /**
    var jsonData={
        content: '张三',
        children: [
            { content: 'one' },
            {
                content: 'two',
                children: [ {content: 'three'} ]
            }
        ]
    }
    **/
    var strJson={{.Node.Content}};
    var jsonData={};
    if (strJson==""){
        jsonData={
        content: '根节点',
        children: [
            { content: '子节点' },
            {
                content: '子节点二',
                children: [ {content: '节点三'} ]
            }
        ]
    }
    }else{
        jsonData=JSON.parse(strJson);
    }
    
    </script>
    <script src="/js/d3.v3.js"></script>
    <script src="/js/build.js"></script>
    <script>
    function save(){
        $.post("/hd/node/update",{Id:id,Content:JSON.stringify(treed.db.exportTree())},function(data){
            swal('发布节点','思维导图保存成功','success');
        });
    }
    </script>
</html>